import common from './common'

const paths = {
  saveProjectCorrection: 'correction/saveProjectCorrection',
  getProjectCorrection: 'correction/getProjectCorrection',
  getParentProjectCorrection: 'correction/getParentProjectCorrection',
  startProjectCorrection: 'correction/startProjectCorrection',
  getCorrectionUnit: 'correction/getCorrectionUnit',
  getProjectComposeUnit: 'correction/getProjectComposeUnit',
  composeEndCopy: 'correction/composeEndCopy'
}

const projectCorrectionService = {};

(function (service) {
  /**
   * 保存补正信息
   * @param list
   * @returns {*}
   */
  service.saveProjectCorrection = (list) => {
    return common.post(paths.saveProjectCorrection, null, list)
  }
  /**
   * 获取补正信息
   * @param projectId
   * state 获取类型，0未结束，1已结束，2所有
   * @returns {*}
   */
  service.getProjectCorrection = (projectId, state = 0) => {
    return common.get(paths.getProjectCorrection, { projectId, state })
  }
  /**
   * 获取补正流程父案件的补正信息
   * @param projectId
   * state 获取类型，0未结束，1已结束，2所有
   * @returns {*}
   */
  service.getParentProjectCorrection = (projectId, state = 0) => {
    return common.get(paths.getParentProjectCorrection, { projectId, state })
  }
  /**
   * 创建补正流程
   * @param parentProjectId
   * @param businessId
   * @param businessProcessId
   * @returns {*}
   */
  service.startProjectCorrection = (parentProjectId, businessId, businessProcessId, processAppId) => {
    return common.postxf(paths.startProjectCorrection, { parentProjectId, businessId, businessProcessId, processAppId })
  }
  /**
   * 获取补正父案件设置的发送科室
   * @param projectId
   * @returns {*}
   */
  service.getCorrectionUnit = (projectId) => {
    return common.get(paths.getCorrectionUnit, { projectId })
  }
  /**
   * 获取补正合卷之前的单位
   * @param projectId
   * @returns {Promise | Promise<unknown>}
   */
  service.getProjectComposeUnit = (projectId) => {
    return common.get(paths.getProjectComposeUnit, { projectId })
  }
  /**
   * 补正结束复制数据
   * @param projectId
   * @param activityName
   * @returns {Promise | Promise<unknown>}
   */
  service.composeEndCopy = (projectId, activityName) => {
    return common.postxf(paths.composeEndCopy, { projectId, activityName })
  }
})(projectCorrectionService)

export default projectCorrectionService
